//
//  LGMedicineHistogramView.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/3/7.
//

#import "LGMedicineHistogramLayer.h"

@interface LGMedicineHistogramLayer()
/**   */
@property (nonatomic , strong)CAShapeLayer *shapeLayer;
/**  漏服 */
@property (nonatomic , strong)CALayer *leaveLayer;

@end

@implementation LGMedicineHistogramLayer

- (instancetype)init{
    self = [super init];
    if(self){
        self.backgroundColor = [UIColor colorWithString:@"#11CCAA"].CGColor;
        [self addSublayer:self.leaveLayer];
    }
    return self;
}

-(void)setPercent:(CGFloat)percent{
    _percent = percent;
    self.leaveLayer.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height*percent);
    [self layoutSublayers];
}

-(void)layoutSublayers{
    [super layoutSublayers];
    self.shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(3, 3)].CGPath;
    self.mask = self.shapeLayer;
}

-(CAShapeLayer *)shapeLayer{
    if(!_shapeLayer){
        _shapeLayer = [CAShapeLayer layer];
    }
    return _shapeLayer;
}

-(CALayer *)leaveLayer{
    if(!_leaveLayer){
        _leaveLayer = [[CALayer alloc] init];
        _leaveLayer.backgroundColor = [UIColor colorWithString:@"#DD3030"].CGColor;
    }
    return _leaveLayer;
}


@end
